﻿Imports Seguros.caserDataSet

Public Class frmLogin


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim sError As String = ""
        Dim caserDataSet As New caserDataSet
        sError = CargarTabla(caserDataSet.login)

        If sError <> "" Then
            MessageBox.Show(sError, Me.Text, MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If
        Dim login = caserDataSet.login.Select("username = '" & txtUsername.Text & "' and  pass = '" & txtPass.Text & "'")
        If login.Count = 1 AndAlso CType(login(0), caserDataSet.loginRow).fecha > Date.Today Then
            Me.Tag = login(0)
            Me.Close()

        Else
            MessageBox.Show("Nombre de usuario o contraseña incorrecto", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End If


    End Sub

    Private Sub frmLogin_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.Tag = Nothing
        txtPass.Focus()
    End Sub





    Private Sub btnSalir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSalir.Click
        Me.Close()
    End Sub

    Private Sub txtPass_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles txtPass.KeyDown
        If e.KeyCode = Keys.Enter Then
            Button1_Click(Button1, New EventArgs)
        End If
    End Sub



    Private Sub txtPass_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPass.TextChanged

    End Sub
End Class